<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--  boostrapcss  -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!--    jquery-->
    <script type="text/javascript" src="js/jquery-3.4.1.min.js" charset="UTF-8"></script>
    <!-- 加载jsRender-->
    <script src="js/jsrender.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/jsrender.min.js" type="text/javascript" charset="UTF-8"></script>
    <!--    boostrapjs-->
    <script type="text/javascript" src="js/bootstrap.bundle.js" charset="UTF-8"></script>
    <script type="text/javascript" src="js/bootstrap.js" charset="UTF-8"></script>
    <script src="js/md5.js" type="text/javascript" charset="UTF-8"></script>
    <style>
        .card-body .card-text{
            font-size: 30px;
            margin-left: 20px;
            font-weight: bolder;
            text-align: center;
        }
        .row, .nav {
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
    <div class="container">
        <ul class="nav nav-tabs">
            <a class="navbar-brand mb-0 h1" href="#">
                <img alt="Brand" src="./images/M.svg" width="25" height="25">
            </a>
            <li class="nav-item">
                <a class="nav-link active" href="./index.html">首页</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="./user.html">用户管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="./product.html">产品管理</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="./note.html">留言管理</a>
            </li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Dropdown</a>
                <div class="dropdown-menu">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <a class="dropdown-item" href="#">Something else here</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Separated link</a>
                </div>
            </li>
        </ul>
    </div>
    <div class="container">
        <div id="body">

        </div>
    </div>
    <script id="testTmpl" type="text/x-jsrender">
        <div class="row">
                <div class="card col">
                    <div class="card-body">
                        <h5 class="card-title">
                            <span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>
                            <span>注册用户总数</span>
                        </h5>
                        <p class="card-text badge badge-primary">{{:userCount}}111</p>
                    </div>
                </div>
                <div class="card col">
                    <div class="card-body">
                        <h5 class="card-title">
                            <span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>
                            <span>上架商品总数</span>
                        </h5>
                        <p class="card-text badge badge-success">{{:productCount}}222</p>
                    </div>
                </div>
                <div class="card col">
                    <div class="card-body">
                        <h5 class="card-title">
                            <span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span>
                            <span>用户留言总数</span>
                        </h5>
                        <p class="card-text badge badge-danger">{{:productNoteCount}}333</p>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col card">
                    <div class="card-body">
                        <h5 class="card-title">
                            今日商品概况
                            <span class="badge">{{:productCount}}</span>
                        </h5>
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>商品id</th>
                                    <th>商品名</th>
                                    <th>销量</th>
                                </tr>
                            </thead>
                            {{for productList}}
                            <tr>
                                <th>{{:pid}}</th>
                                <th>{{:pname}}</th>
                                <th>{{:sales}}</th>
                            </tr>
                            {{/for}}
                        </table>
                    </div>
                </div>
                <div class="col card">
                    <div class="card-body">
                        <h5 class="card-title">
                            <span>今日用户概况
                            <span class="badge">{{:userCount}}</span>
                        </span>
                        </h5>
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>用户id</th>
                                    <th>用户名</th>
                                    <th>时间</th>
                                </tr>
                            </thead>

                            {{for userList}}
                            <tr>
                                <th>{{:uid}}</th>
                                <th>{{:username}}</th>
                                <th>{{:modifytime}}</th>
                            </tr>
                            {{/for}}
                        </table>
                    </div>
                </div>
            </div>
    </script>
    <script>
        var htmlOutput;
        var datas = {};
        $(document).ajaxSuccess(function () {

        });
        $.get("http://localhost:8080/ycumall/api/admin.do?method=getHome",
            function(data) {
                datas = data;
                $.templates("personTmpl", "#testTmpl");;
                htmlOutput = $.render.personTmpl(data);
                $("#body").html(htmlOutput);
            });
    </script>
</body>
</html>